home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / giochi / chinacha.lha / ChinaChallenge3 / C++ / stubs.c < prev    next >
C/C++ Source or Header  |  1994-05-09  |  680b  |  44 lines

  1. #include <exec/memory.h>
  2. #include <proto/exec.h>
  3.  
  4. #define ALIAS(a,b) asm(".stabs \"_" #a "\",11,0,0,0\n.stabs \"_" #b "\",1,0,0,0")
  5.  
  6. #if 1 /* own memory allocation */
  7.  
  8. void *__builtin_new(ULONG size)
  9. {
  10.   ULONG *a;
  11.  
  12.   size = (size+3*sizeof(ULONG)-1)&~(2*sizeof(ULONG)-1);
  13.   if (a=(ULONG*)AllocMem(size,MEMF_CLEAR))
  14.     *a++=size;
  15.   return (void *)a;
  16. }
  17.  
  18. void __builtin_delete(void *mem)
  19. {
  20.   ULONG size;
  21.  
  22.   if (mem)
  23.   {
  24.     size=(ULONG)*(--((ULONG *)mem)); FreeMem(mem,size);
  25.   }
  26. }
  27.  
  28. #else /* use system functions */
  29.  
  30. void *__builtin_new(unsigned long size)
  31. {
  32.   return malloc(size);
  33. }
  34.  
  35. void __builtin_delete(void *mem)
  36. {
  37.   free(mem);
  38. };
  39.  
  40. #endif
  41.  
  42. ALIAS(_main,main);
  43. ALIAS(exit,_exit);
  44.